package com.appspot.entourage.ui.server;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.entourage.explorer.Explorer;


public class TaskServlet extends HttpServlet {
 
 private static final long serialVersionUID = 8032611514671727168L;
 

 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	ServerManager serverManager = new ServerManager();
	 try {
   
		int radius = 0;
		
		String url = "";
		
		if(req.getParameter("url") != null)
			url = req.getParameter("url");
		
		if(req.getParameter("radius") != null)
			radius = Integer.parseInt(req.getParameter("radius"));
		
		serverManager.runJob(radius, url);
		
		PrintWriter writer = resp.getWriter();
		writer.write("OK");
		writer.flush();
	   
	} 
		catch (Exception e) {   
		e.printStackTrace();
		throw new ServletException(e);
	}
  
 }
 
}
